package com.aba.hos.doc.entity;


import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * 病人实体类，存储病人基本信息
 */
public class Patient {
    private static int nextId = 1000;
    private int id;
    private String adminId;
    private String name;
    private int age;
    private String gender;
    private String diagnosis;
    private Timestamp admissionDate;
    private Doctor attendingDoctor;
    private Ward ward;
    private boolean isDischarged;
    private String docId;
    private String bedNumber;

    public Patient(String name, int age, String gender, String diagnosis,String bedNumber,String docId,String adminId) {
        this.adminId = adminId;
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.diagnosis = diagnosis;
        this.admissionDate = Timestamp.valueOf(LocalDateTime.now());
        this.isDischarged = false;
        this.docId = docId;
        this.adminId = adminId;
        this.bedNumber =bedNumber;
    }
    public Patient() {
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getBedNumber() {
        return bedNumber;
    }

    public void setBedNumber(String bedNumber) {
        this.bedNumber = bedNumber;
    }

    public String getAdminId() {
        return adminId;
    }

    public String getDocId() {
        return docId;
    }

    public void setDocId(String docId) {
        this.docId = docId;
    }

    public void setAdminId(String adminId) {
        this.adminId = adminId;
    }

    // Getters and Setters
    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getDiagnosis() {
        return diagnosis;
    }

    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }

    public Timestamp  getAdmissionDate() {
        return admissionDate;
    }

    public void setAdmissionDate(Timestamp admissionDate) {
        this.admissionDate = admissionDate;
    }

    public Doctor getAttendingDoctor() {
        return attendingDoctor;
    }

    public void setAttendingDoctor(Doctor attendingDoctor) {
        this.attendingDoctor = attendingDoctor;
    }

    public Ward getWard() {
        return ward;
    }

    public void setWard(Ward ward) {
        this.ward = ward;
    }

    public boolean isDischarged() {
        return isDischarged;
    }

    public void discharge() {
        this.isDischarged = true;
        if (this.ward != null) {
            this.ward.removePatient(this);
            this.ward = null;
        }
        if (this.attendingDoctor != null) {
            this.attendingDoctor.removePatient(this);
            this.attendingDoctor = null;
        }
    }

    @Override
    public String toString() {
        return "Patient{id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", diagnosis='" + diagnosis + '\'' +
                ", admissionDate=" + admissionDate +
                ", attendingDoctor=" + (attendingDoctor != null ? attendingDoctor.getName() : "None") +
                ", ward=" + (ward != null ? ward.getWardNumber() : "None") +
                ", isDischarged=" + isDischarged +
                ", adminId=" + adminId +
                ", docId=" + docId +
                ", bedNumber=" + bedNumber +
                '}';
    }
}    